package cz.worsik.android.test.rideshare.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import java.util.List;

import cz.worsik.android.test.rideshare.R;
import cz.worsik.android.test.rideshare.model.Contact;

/**
 * Created by 231260 on 4.1.14.
 */
public class ContactAdapter extends ArrayAdapter<Contact> {

    SQLiteDatabase db;
    List<Contact> items;

    public ContactAdapter(Context context, int resource) {
        super(context, resource);
    }

    public void setDb(SQLiteDatabase db) {
        this.db = db;
    }

    public void setItems(List<Contact> items)
    {
        /*int i = 0;
        for (Contact c : items)
        {
            this.insert(c,i++);
        }*/
        this.items = items;
    }

    public View getView(int position, View convertView, ViewGroup parent)
    {
        View radek = super.getView(position,convertView,parent);

        TextView label = (TextView) radek.findViewById(R.id.contact_list_label);
        label.setText(items.get(position).getName());

        return radek;
    }
}
